<style type="text/css">
    .selected-search {
        border: 1px solid #dddee1;
        height: 200px;
        width: 260px;
        position: relative;
        border-radius: 4px;
    }

    .selected-search .search-action {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .selected-search .selected-arr {
        position: absolute;
        top: 50px;
        left: 20px;
        right: 20px;
        bottom: 10px;
        overflow: scroll;
    }

    .select-click {
        border: 1px solid #dddee1;
        border-radius: 4px;
        padding: 0 10px;
        margin-bottom: 10px;
    }

    .selected-search .selected-arr .selected-item {
        /*border-bottom: 1px solid #dfdfdf;*/
    }
</style>
<template>
    <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="110">
        <Form-item label="维修人姓名" prop="repairpeople">
            <i-input v-model="formValidate.repairpeople" placeholder="请输入联系人"></i-input>
        </Form-item>
        <Form-item label="维修人电话" prop="repaircontact">
            <i-input v-model="formValidate.repaircontact" placeholder="请输入联系人电话"></i-input>
        </Form-item>
        <Form-item label="预约时间">
            <Row>
                <i-col span="11">
                    <Date-picker type="datetime" placeholder="选择预约时间"  @on-change="changeStartDate" ></Date-picker>
                </i-col>
            </Row>
        </Form-item>
        <Form-item label="维修时间">
            <Row>
                <i-col span="11">
                    <Date-picker type="datetime" placeholder="选择维修时间"  @on-change="changeEndDate"  ></Date-picker>
                </i-col>
            </Row>
        </Form-item>
        <Form-item>
            <i-button @click="handleSubmit('formValidate')" type="primary">派工</i-button>
            <i-button type="ghost" style="margin-left: 8px">取消</i-button>
        </Form-item>
    </i-form>

</template>
<script>
    import apiUtil from '../../assets/utils/api_util';

    export default {
        data() {
            return {
                formValidate: {
                    //添加字段
                    repaircontact: '',
                    repairpeople: '',
                    state:'派工',
                    predate:'',
                    repairdate:''
                },
                ruleValidate: {
                    people: [
                        {required: true, message: '联系人不能为空', trigger: 'blur'}
                    ],
                    contact: [
                        {required: true, message: '联系人电话不能为空', trigger: 'blur'}
                    ],
                    repaircontact: [
                        {required: true, message: '维修人电话不能为空', trigger: 'blur'}
                    ],
                    repairpeople: [
                        {required: true, message: '维修人不能为空', trigger: 'blur'}
                    ],
                },
                editType:'',
            }
        },
        mounted: function () {
            let id = this.$route.query.id;
            this.editType = this.$route.query.type;

            if (id && id.length > 0) {

                // this.getDetail(id)
            }

        },

        methods: {
            changeStartDate: function (date) {
                this.formValidate.predate = date;
            },
            changeEndDate: function (date) {
                this.formValidate.repairdate = date;

            },
            handleSubmit(name) {

                let that = this;
                let model = this.$refs[name].model;
                this.$refs[name].validate((valid) => {
                    that.updateData(model);
                })
            },
            //详情
            getDetail: function (id) {
                let that = this;
                that.$Loading.start();

                let para = {
                    id: id,
                };
                apiUtil.get(that, apiUtil.urls.GetVisitorDetail, para, function (res) {
                    that.$Loading.finish();

                    that.formValidate.people = res.Msg.people;
                    that.formValidate.phone = res.Msg.phone;
                    that.formValidate.cartype = res.Msg.cartype;
                    that.formValidate.carcode = res.Msg.carcode.split('-')[1];
                    that.personalName = res.Msg.carcode.split('-')[0];
                    that.formValidate.state = res.Msg.state;
                    that.formValidate.expiredatestart = res.Msg.expiredatestart;
                    that.formValidate.expiredateend = res.Msg.expiredateend;
                    that.visitorid =res.Msg.visitorid;
                    that.getPaperData();
                    // that.formValidate.state =res.data.state.toString();
                });
            },
            //修改
            updateData: function (model) {
                let that = this;

                model.opid = '87415a1b-922e-4a94-83c6-8f16c74ab0fb';


                let params = that.$qs.stringify(model);

                this.$Loading.start();

                apiUtil.post(that,apiUtil.urls.EditRepairForm, params, function (res) {
                    that.$Loading.finish();
                    that.$message.success('编辑成功')
                });
            },


        }
    }
</script>
